<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<img src="" alt="" nihao="123" id="test">
<script>
    var elementById = document.getElementById('test');
    console.log(elementById)
    console.log(elementById.getAttribute('nihao'))
    alert(elementById.getAttribute('nihao'))
</script>
</body>
</html>